<template>
    <div>
        <div class="list">
          <template v-for="(item, index) in list">
            <div class="item" :key="index" @click="toDetail(item.id)">
              <div class="left">
                <img :src="item.head_sculpture ? item.head_sculpture : avatar" alt="" width="40" height="40">
                <span>{{ item.name }}</span>
              </div>
              <!-- <img src="@/assets/img/icon-edit.png" alt="" width="20" @click="toDetail(item.id)"> -->
            </div>
            <van-divider :key="index"/>
          </template>
        </div>
    </div>
</template>

<script>
import api from '@/api'
export default {
  name: 'index',
  data () {
    return {
      avatar: require('@/assets/img/icon-avatar.png'),
      type: '1',
      search: '',
      list: []
    }
  },
  methods: {
    getStudent () {
      let params = {
        subsidiary: JSON.parse(sessionStorage.getItem('user')).id
        // subsidiary: '1'
      }
      if (this.search) {
        params.name = this.search
      }
      api.agencyGetStudent({
        params,
        callback: res => {
          this.type = '2'
          if (res.data.error_code === 0) {
            this.list = res.data.data
          }
        }
      })
    },
    onSearch () {},
    toDetail (id) {
      this.$router.push({path: '/studentCheck', query: {data: id}})
    }
  },
  created () {
    this.getStudent()
  }
}
</script>

<style scoped>
  .top-bar{
    font-family: PingFangBlod;
    color: #1E1E1E;
    display: flex;
    align-items: center;
    padding: 10px 16px;
    box-shadow:0px 3px 6px rgba(0,0,0,0.16);
    font-size: 18px;
  }
  .top-bar .bar-item{
    flex-grow: 1;
    flex-shrink: 1;
    text-align: center;
    position: relative;
  }
  .top-bar .bar-item:nth-child(1){
    border-right: 1px solid #707070;
  }
  .top-bar .bar-item.active{
    color: #3A7FE2;
  }
  .bar-item.active .bottom-line{
    position: absolute;
    display: inline-block;
    height: 3px;
    width: 50px;
    background-color: #3a7fe2;
    bottom: -10px;
    left: 50%;
    margin-left: -25px;
  }
  .top-bar .message{
    flex-grow: 0;
    flex-shrink: 0;
  }
  .top-bar .message img{
    display: block;
  }
  .content .container{
    height: calc(100% - 56px);
    margin-top: 10px;
    overflow: auto;
  }
  .list .item{
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .list .item .left{
    display: flex;
    align-items: center;
    padding: 10px;
  }
  .item .left span{
    color: #1A1D20;
    font-family: PingFangBlod;
  }
  .list .item img{
    margin-right: 10px;
  }
  .van-divider{
    margin: 0;
  }
</style>
